<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/css.jsp"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">	
		<script type="text/javascript" src="${base }/js/DatePicker/WdatePicker.js"></script>
		<script type="text/javascript" src="${base }/js/jquery/jquery-1.3.min.js"></script>
		<script type="text/javascript" src="${base }/js/jquery/lhgdialog/lhgcore.min.js"></script>
		<script type="text/javascript" src="${base }/js/jquery/lhgdialog/lhgdialog.min.js"></script>
		<script type="text/javascript" src="${base }/js/page.js"></script>
		
		<script language="javascript">
		 jQuery(document).ready(function(){			   		
			  
			   //全选事件
			   jQuery("#idsAll").click(function(){ 
			       var checked = jQuery(this).attr("checked");
				   jQuery("input[name='userChk']").attr("checked",checked);
			   });		
			   
			   //添加按钮单击事件
			   jQuery(".addBtn").click(function(){
			   		var param = parent.treeFrame.getSelectedNodeId();
					if(param ==null || param.orgId == -1 || param.orgId == null || param.orgCode == ""){
						alert("请先在左侧选择相应的部门，然后再单击添加铵钮在该部门下添加用户信息!");
						return;
					}
					param.operate = "add";
				    var dg = new J.dialog({ title: '添加用户信息对话框', 
				    	iconTitle:false,maxBtn:false,resize:false,
				    	cover:true,width:800,height:400,
				    	page: '${base}/forward?url=pages.user.userView',
				    	args:param});
					dg.ShowDialog();
			   });
			   
			   //修改按钮单击事件
			   jQuery(".updateBtn").click(function(){
			   		var param = {};
			   		param.operate = "update";
			   		param.userId = jQuery(this).val();
				    var dg = new J.dialog({ title: '修改用户信息对话框', 
				    	iconTitle:false,maxBtn:false,resize:false,
				    	cover:true,width:800,height:400,
				    	page: '${base}/forward?url=pages.user.userView',
				    	args:param});				    	
					dg.ShowDialog();
			   });
			   
			   	//查看按钮单击事件
			   jQuery(".showBtn").click(function(){
			   		var param = {};
			   		param.operate = "show";
			   		param.userId = jQuery(this).val();
				    var dg = new J.dialog({ title: '查看用户信息对话框', 
				    	iconTitle:false,maxBtn:false,resize:false,
				    	cover:true,width:800,height:400,
				    	page: '${base}/forward?url=pages.user.userView',
				    	args:param});				    	
					dg.ShowDialog();
			   });
			   
			   //删除按钮单击事件
			   jQuery(".deleteBtn").click(function(){
			   		if(confirm("你确认要删除该用户信息吗？")){
			   			var param = {};
			   			param.userId = jQuery(this).val();;
			   			jQuery.post("${base}/user/delete",param,function(data,textStatus,jqXHR){
							if(data.success){
								alert("删除成功!");
							}else{
								alert("删除失败!");
							}
						},'json');		
			   		}			   		
			   });
			   
			   //批量删除单击事件
			   jQuery("#btn_del").click(function(){
			   		if(confirm("你确认要批量删除选中的用户信息吗？")){
			   			var $userChk = jQuery("input[name='userChk']:checked");
			   			if($userChk == null || $userChk.size() == 0){
			   				alert("请先勾选中要删除的用户信息记录，再单击批量删除!");
			   				return;
			   			}
			   			var userIds = "";
			   			$userChk.each(function(){
			   				userIds += jQuery(this).val() + ",";
			   			});		
			   			var param = {};	   			
			   			param.userIds = userIds.substring(0,userIds.length - 1);
			   			jQuery.post("${base}/user/batchDelete",param,function(data,textStatus,jqXHR){
							if(data.success){
								alert("批量删除成功!");
							}else{
								alert("批量删除失败!");
							}
						},'json');		
			   		}	
			   });
			   
			   //重置密码按钮
			   jQuery(".resetPwdBtn").click(function(){
			   		 var param = {};
			   		 param.userId = jQuery(this).val();
			   		 var dg = new J.dialog({ title: '重置密码对话框', 
				    	iconTitle:false,maxBtn:false,resize:false,
				    	cover:true,width:500,height:200,
				    	page: '${base}/forward?url=pages.user.resetPwd',
				    	args:param});				    	
					dg.ShowDialog();
			   });
			   
		  });
		</script>
	<title>用户管理</title>
	</head>
	<body>
		<table width="99%" border="0" cellspacing="0" cellpadding="0" align="center">
			<tr>
				<td>
					<div class="biaoge">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td colspan="6" class="biaoge_bg01" >
									用户列表
								</td>
							</tr>
							<tr>
								<td align="right" colspan="6" class="biaoge_bg02">
									<input type="button" value="添加" class="anniu addBtn"/>
									<input type="button" value="批量删除" id="btn_del" class="anniu">
								</td>
							</tr>
							<tr>
								<td>
									<table width="100%" border="0" cellspacing="1" cellpadding="0"
										class="FindAreaTable1" ID="DataGrid1">
										<tr>
											<th width="2%">
												<input type="checkbox" name="idss" id="idsAll">
											</th>
											<th width="20%">
												姓名
											</th>
											<th width="15%">
												用户名
											</th>
											<th width="12%">
												联系电话
											</th>
											<th width="11%">
												移动电话号码
											</th>
											<th width="10%">
												QQ号码
											</th>
											<th width="10%">
												创建时间
											</th>
											<th width="20%">
												操作
											</th>
										</tr>
										<c:choose>
											<c:when test="${pm.result eq null}">
												<tr>
													<td colspan="8">没有用户信息</td>
												</tr>
											</c:when>
											<c:otherwise>
												<c:forEach var="user" items="${pm.result}" varStatus="status">
													<tr>
														<td>
															<c:choose>
																<c:when test="${user.id eq 0}">
																	<input type="checkbox"  disabled/>
																</c:when>
																<c:otherwise>
																	<input type="checkbox" name="userChk" value="${user.id}"/>
																</c:otherwise>
															</c:choose>
														</td>
														<td>${user.fullName}</td>
														<td>${user.userName}</td>	
														<td>${user.phone}</td>	
														<td>${user.mobPhone}</td>	
														<td>${user.qq}</td>	
														<td>${user.createTime}</td>											
														<td>
															<c:choose>
																<c:when test="${user.id eq 0}">
																	&nbsp;
																</c:when>
																<c:otherwise>
																	<a href="#" name="a_modify" class="updateBtn" value="${user.id}">修改</a>&nbsp;
																	<a href="#" name="a_show" class="showBtn" value="${user.id}">查看</a>&nbsp;
																	<a href="#" name="a_del" class="deleteBtn" value="${user.id}">删除</a>&nbsp;
																	<a href="#" name="a_del" class="resetPwdBtn" value="${user.id}">重置密码</a>&nbsp;
																</c:otherwise>
															</c:choose>															
														</td>
													</tr>
												</c:forEach>
											</c:otherwise>
										</c:choose>	
										<tr>
										<td colspan="8">
											<!-- 分页信息 -->
											<div class="pagination" style="text-align:right"> 
												<c:if test="${pm.result ne null}">
												<script>
													var pg = new showPages('pg');
													pg.pageCount = ${pm.maxPage};
													pg.argName = 'currentPage';
													pg.printHtml();  
												</script>
												</c:if>
											</div>
											<!-- End .pagination -->
											<div class="clear"></div>
										</td>
									</tr>
									</table>
								</td>
							</tr>																
						</table>
					</div>
				</td>
			</tr>
		</table>

	</body>
</html>
<script language="JavaScript">


function edit(){
    var operate = "modify";
    var dg = new J.dialog({ title: '修改元数据标准对话框', iconTitle:false,maxBtn:false,resize:false,cover:true,width:650,height:280,page: '../../共享资源编目/元数据标准规划/newyuanshujubiaozhun.html',args:operate});
	dg.ShowDialog();
	dg.addBtn("btn_confirm","确定",function(){alert("修改成功!");dg.cancel();},"left");
	//document.location.href="edityuanshujubiaozhun.html";
}

function del(){
	var idsnum=document.getElementsByName('id');
	var groupID='';
	var j=0;
	
	for( var i=0;i<idsnum.length;i++){
		if(idsnum[i].checked){
			j++;
			groupID+=idsnum[i].value+",";
		}
	}
	
	if(j==0){
		alert("请至少选择一个！");
		return false;
	}
	//alert(groupID);
	else if(confirm("您确定要删除这"+j+"条吗？")){
	    document.location.href="biaozhun.html";
		alert("删除成功！");
 	}
}
function del2(){
 if(confirm("您确定要删除吗？")){
	    document.location.href="biaozhun.html";
		alert("删除成功！");
 	}
	else{return false;}
}

function fabu(){
	var idsnum=document.getElementsByName('id');
	var groupID="";
	var j=0;
	for( var i=0;i<idsnum.length;i++){
		if(idsnum[i].checked){
		    groupID=idsnum[i].value;
			j++;
		}
	}
	
	if(j==0){
		alert("请您请选择一个或多个！");
		return false;
	}
	if(confirm("您确定要发布这"+j+"个标准吗？")){
	    document.location.href="biaozhun.html";
		alert("发布成功！");
 	}
	else{return false;}
    document.location.href="biaozhun.html";

}

function stop(){

	var idsnum=document.getElementsByName('id');
	var groupID="";
	var j=0;
	for( var i=0;i<idsnum.length;i++){
		if(idsnum[i].checked){
		    groupID=idsnum[i].value;
			j++;
		}
	}
	
	if(j==0){
		alert("请您请选择一个或多个！");
		return false;
	}
	if(confirm("您确定要停用这"+j+"个标准吗？")){
	    document.location.href="biaozhun.html";
		alert("停用成功！");
 	}
	else{return false;}
    document.location.href="biaozhun.html";

}
function searchh(){
     document.location.href="biaozhun.html";
}
 

function show(){
     var operate = "show";
	 var dg = new J.dialog({ title: '查看元数据标准对话框', cancelBtnTxt:'关闭',iconTitle:false,maxBtn:false,resize:false,cover:true,width:550,height:280,page: '../../共享资源编目/元数据标准规划/newyuanshujubiaozhun.html',args:operate});
	 dg.ShowDialog();
		//dg.addBtn("btn_confirm","确定",function(){alert("修改成功!");dg.cancel();},"left");

	// window.open('../../test.html','','height=400, width=750, top=100,left=150, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no' );
}
 
//新的dialog方式
 function mingxidialog(){
 	var dlg = new J.dialog({ id: 'd1', title: '明细', page: '../../元数据标准规划/dialogyuanshujubiaozhun.html',width:700,height:280});
    	dlg.ShowDialog();
 }
</script>
